package org.home.learning;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

//import javax.imageio.ImageIO;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class Redimensiona {
	
	public static String Arq = new String(); 
	public static String ArqBanco = new String();
	public static ImageIcon imgIcon = new ImageIcon();
	
	public Redimensiona() throws IOException {
		
		try {
			
		BufferedImage img = ImageIO.read(new File(SelecionaImagem.caminhoArquivo));
		int new_w = 300, new_h = 200;
		BufferedImage new_img = new BufferedImage(new_w, new_h, BufferedImage.TYPE_INT_RGB);
		new_img.createGraphics().drawImage(img, 0, 0, new_w, new_h, null);
		ImageIO.write(new_img, "JPEG", new File("C:\\users\\jspereira\\desktop\\App_pictures\\" + SelecionaImagem.NomeArquivo));    
		Arq = ("C:\\users\\jspereira\\desktop\\App_pictures\\" + SelecionaImagem.NomeArquivo);
		ArqBanco = Arq.replace("\\", "\\\\");
		
		imgIcon = new ImageIcon(Arq);
		
		System.out.print("Redimensiona logo badarosca");
			}
		
		catch (Exception e) {
			System.out.println("Impossivel redimensionar");
		}
	}

}
